package cn.tedu.micro.demo.amqp;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.annotation.RabbitListeners;
import org.springframework.stereotype.Component;


/**
 * 监听demo_queue 出现消息我就消费
 */
@Component
@Slf4j
public class AmqpConsumer {

    //消费方法 每当有一个消息出现在demo_queue,方法就会被调用一次
    /*@RabbitListener(queues = "demo_queue")
    public void receive(String msg){
        log.info("收到消息:{}",msg);
    }*/
    /*@RabbitListener(queues = "demo_queue")
    public void receive(Message msg){
        log.info("收到消息:{}",msg);
    }*/
    @RabbitListener(queues = "demo_queue")
    public void receive(String message,Message msg, Channel channel){
        log.info("收到消息:{}",message);
        log.info("channel:{}",channel);
        log.info("msg:{}",msg);
    }
}
